{extend name="public/base" /}

{block name="content"}
<style>
    .img-responsive [data-ratio="16:9"]{
        height: 7rem;
    }
    .test{
        border-radius: 0%;
        width: 100%;
        padding-bottom: 6%;
        line-height:9vw;
    }
</style>
<!--页面路径 和 页面标题-->
<div class="page-title">

    <div class="title-env">
        <h1 class="title">系统设置</h1>
        <p class="description">分享设置</p>
    </div>

    <div class="breadcrumb-env">

        <ol class="breadcrumb bc-1">
            <li>
                <a href="/admin"><i class="fa-home"></i>Home</a>
            </li>
            <li>
                <a href="">系统设置</a>
            </li>
            <li class="active">
                <strong>分享设置</strong>
            </li>
        </ol>

    </div>

</div>

<div class="row">
    <div class="col-md-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">分享设置</font></font></h3>
            </div>

            <div class="panel-body">
                <form id="edit-form" method="post" class="form-horizontal" action="/admin/system/share">
                   <!-- <input type="hidden" name="share_video_url" id="video_url" value="{$configs.share_video_url}">
                    <div class="form-group" style="text-align: center">
                        <label class="col-sm-2 control-label">文件预览</label>
                        <div class="col-sm-3">
                            <video src="{$configs['share_video_url']}" id="show_video_url" class="test" controls="controls"></video>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label">文件上传</label>
                        <div class="col-sm-3">
                            <div id="advancedDropzone1" class="droppable-area test">
                                点击上传视频
                            </div>
                        </div>
                    </div>-->

                    <div class="form-group">
                        <label class="col-sm-2 control-label">app下载链接</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="share_app_url" value="{$configs['share_app_url']}">
                        </div>
                    </div>

                    <div class="form-group">
                        <input type="button" class="btn btn-info btn-single pull-right" id="edit-button" value="Save changes">
                    </div>

                </form>
            </div>
        </div>
    </div>
</div>
{/block}

{block name="modal"}

<div class="modal fade bs-example-modal-lg" id="upload-show" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">上传进度</h4>
            </div>
            <div class="modal-body">
                <div class="page-container">
                    <div class=" main-content ">
                        <div class="row table-responsive">
                            <table class="table table-bordered table-striped" id="example-dropzone-filetable">
                                <thead>
                                <tr>
                                    <th class="text-center">#</th>
                                    <th>Name</th>
                                    <th>Upload Progress</th>
                                    <th>Size</th>
                                    <th>Status</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr>
                                    <td colspan="5">Files list will appear here</td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>

                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-warning" id="cancel">取消上传</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>
{/block}

{block name="js"}
<!--<script src="/static/assets/js/dropzone/dropzone.js"></script>-->

<script>
    //编辑分类表单提交
    $("#edit-button").click(function(){
        var targetUrl = $("#edit-form").attr("action");
        var data = $("#edit-form").serialize();
        $.ajax({
            type:'post',
            url:targetUrl,
            cache: false,
            data:data,
            dataType:'json',
            success:function(res){
                if(res.code == 0) {
                    error(res.msg)
                    setTimeout("window.location.href='/admin/system/share'",1000);
                }else{
                    success(res.msg);
                    setTimeout("window.location.href='/admin/system/share'",1000);
                }
            }
        })
    });

</script>

<!--<script type="text/javascript">
    jQuery(document).ready(function($)
    {
        var i = 1,
        $example_dropzone_filetable = $("#example-dropzone-filetable"),

        example_dropzone1 = $("#advancedDropzone1").dropzone({
            url: '/admin/video/uploadVideo',
            parallelUploads: 1,//一次上传的文件数量
            maxFiles:1,//一次性上传的文件数量上限
            maxFilesize:500, //上传文件最大尺寸
            init: function () {
                var submitButton = document.querySelector("#cancel")
                myDropzone1 = this;
                submitButton.addEventListener("click", function () {
                    myDropzone1.removeAllFiles(true);
                });
            },
            // Events
            addedfile: function(file)
            {
                $('#upload-show').modal('toggle')
                $example_dropzone_filetable.find('tbody').html('');

                var size = parseInt(file.size/1024, 10);
                size = size < 1024 ? (size + " KB") : (parseInt(size/1024, 10) + " MB");

                var	$el = $('<tr>\
													<td class="text-center">'+(i++)+'</td>\
													<td>'+file.name+'</td>\
													<td><div class="progress progress-striped"><div class="progress-bar progress-bar-warning"></div></div></td>\
													<td>'+size+'</td>\
													<td>Uploading...</td>\
												</tr>');

                $example_dropzone_filetable.find('tbody').append($el);
                file.fileEntryTd = $el;
                file.progressBar = $el.find('.progress-bar');
            },

            uploadprogress: function(file, progress, bytesSent)
            {
                file.progressBar.width(progress + '%');
            },

            success: function(file,res)
            {
                file.fileEntryTd.find('td:last').html('<span class="text-success">Uploaded</span>');
                file.progressBar.removeClass('progress-bar-warning').addClass('progress-bar-success');
                if(res.code == 0) {
                    $('#edit-form #video_url').val(res.data.url);
                    $('#edit-form #show_video_url').attr('src',res.data.url);
                    success(res.message);
                    $('#upload-show').modal('toggle')
                }else{
                    error(res.message);
                }

            },

            //取消上传
            canceled: function (file) {
                file.fileEntryTd.find('td:last').html('<span class="text-danger">Cancel</span>');
                file.progressBar.removeClass('progress-bar-warning').addClass('progress-bar-red');
            },

            error: function(file)
            {
                file.fileEntryTd.find('td:last').html('<span class="text-danger">Failed</span>');
                file.progressBar.removeClass('progress-bar-warning').addClass('progress-bar-red');
            }
        });
    });
</script>-->
{/block}